import redis

from utils.common_util import get_app

app = get_app()


class RedisUtil:
    def __init__(self, host, port, password):
        self.r = redis.StrictRedis(host=host, port=port, password=password)

    def set(self, key, val):
        return self.r.set(key, val)

    def get(self, key):
        return self.r.get(key)

    def get_list(self, key):
        return self.r.lrange(key, 0, -1)


redis_template = RedisUtil(app.config['REDIS_HOST'], app.config['REDIS_PORT'], app.config['REDIS_PASSWORD'])

if __name__ == '__main__':
    redis = RedisUtil('150.158.26.17', port='6379', password='123456')
    print(redis.set('test', 'test'))
